import { Model, DataTypes } from 'sequelize';
import SequelizeClient from '../sequelizeclient';

let sequelize = SequelizeClient.getInstance();
class User extends Model {}
const userInit = () => {
  console.log('user table init');
  User.init(
    {
      username: DataTypes.STRING,
      birthday: DataTypes.DATE,
    },
    { sequelize, modelName: 'user' },
  );
};
const userInsert = async user => {
  sequelize
    .sync()
    .then(() => User.create(user))
    .then(jane => {
      console.log(jane.toJSON());
    });
};

export default {
  userInit,
  userInsert,
};
